package com.atguigu.lease.web.admin.custom.converter;

import com.atguigu.lease.model.enums.ItemType;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import javax.xml.transform.Source;

//单一的参数转换
@Component
public class StringToItemTypeConverter implements Converter<String, ItemType> {
    @Override
    public ItemType convert(String source) {
        int code = Integer.valueOf(source);
        if(code == 1){
            return ItemType.APARTMENT;
        }
        if(code == 2){
            return ItemType.ROOM;
        }
        return null;
    }
}
